package com.leyou.order.config;

import com.github.wxpay.sdk.WXPay;
import com.github.wxpay.sdk.WXPayConfigImpl;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PayConfiguration {

    /**
     * @ConfigurationProperties注解放在方法上，
     * 可以自动给里面初始化的对象属性赋值
     * @return
     */
    @Bean
    @ConfigurationProperties(prefix = "ly.pay.wx")
    public WXPayConfigImpl payConfig(){
        return new WXPayConfigImpl();
    }

    @Bean
    public WXPay createWXPay(WXPayConfigImpl payConfig) throws Exception {
        return new WXPay(payConfig);
    }


}
